package com.zs4sdk.entity;

import org.json.JSONException;
import org.json.JSONObject;

import com.common.library.entity.JSONResultEntity;
import com.common.library.util.Helper;

/**
 * 
 * function: 订单返回json类
 * 
 * @ author: aXiBa
 */
public class OrderResultEntity extends JSONResultEntity {

	public static final String COLUMN_ERRCODE = "errcode";
	public static final String COLUMN_SUCCESS = "success";
	public static final String COLUMN_MESSAGE = "message";
	public static final String COLUMN_ORDERID = "orderid";
	public static final String COLUMN_GOODSID = "goodsid";
	public static final String COLUMN_GOODSNAME = "goodsname";
	public static final String COLUMN_GOODSDESC = "goodsdesc";
	public static final String COLUMN_GOODSFEE = "goodsfee";
	public static final String COLUMN_NOTIFYURL = "notifyurl";
	public static final String COLUMN_INFO = "info";
	public static final String COLUMN_MERCHANTID = "merchantId";
	// 厂商的订单号
	public static final String COLUMN_PCORDERID = "cporderid";
	// 厂商的订单号
	public static final String COLUMN_SIGN = "sign";

	private String message;
	private String errcode;
	private String success;
	private String orderid;
	private String goodsid;
	private String goodsname;
	private String goodsdesc;
	private String goodsfee;
	private String notifyurl;
	private String info;
	private String merchantId;
	private String pcorderid;
	private String sign;
	
	/**
	 * 构造方法
	 */
	public OrderResultEntity(){
		
	}
	/**
	 * 构造方法
	 * @param json
	 */
	public OrderResultEntity(JSONObject json){
		this.fromJSON(json);
	}
	/**
	 * 构造方法
	 * @param jsonStr
	 */
	public OrderResultEntity(String jsonStr){
		try{
			this.fromJSON(new JSONObject(jsonStr));
		}catch (Exception e) {
			e.printStackTrace();
		}
	}

	//#endregion 构造方法

	//#region Override方法
	@Override
	public JSONObject toJSON() {
		JSONObject result = super.toJSON();
		try {
			result.put(COLUMN_MESSAGE, this.message);
			result.put(COLUMN_ERRCODE, this.errcode);
			result.put(COLUMN_SUCCESS, this.success);
			result.put(COLUMN_ORDERID, this.orderid);
			result.put(COLUMN_GOODSID, this.goodsid);
			result.put(COLUMN_GOODSNAME, this.goodsname);
			result.put(COLUMN_GOODSDESC, this.goodsdesc);
			result.put(COLUMN_GOODSFEE, this.goodsfee);
			result.put(COLUMN_NOTIFYURL, this.notifyurl);
			result.put(COLUMN_INFO, this.info);
			result.put(COLUMN_MERCHANTID, this.merchantId);
			result.put(COLUMN_PCORDERID, this.pcorderid);
			result.put(COLUMN_SIGN, this.sign);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return result;
	}
	
	@Override
	public void fromJSON(JSONObject json) {
		super.fromJSON(json);
		if (Helper.isNotEmpty(json)) {
			this.message = json.optString(COLUMN_MESSAGE);
			this.errcode = json.optString(COLUMN_ERRCODE);
			this.success = json.optString(COLUMN_SUCCESS);
			this.orderid = json.optString(COLUMN_ORDERID);
			this.goodsid = json.optString(COLUMN_GOODSID);
			this.goodsname = json.optString(COLUMN_GOODSNAME);
			this.goodsdesc = json.optString(COLUMN_GOODSDESC);
			this.goodsfee = json.optString(COLUMN_GOODSFEE);
			this.notifyurl = json.optString(COLUMN_NOTIFYURL);
			this.info = json.optString(COLUMN_INFO);
			this.merchantId = json.optString(COLUMN_MERCHANTID);
			this.pcorderid = json.optString(COLUMN_PCORDERID);
			this.sign = json.optString(COLUMN_SIGN);
		}
	}

	/**
	 * 是否成功
	 */
	public boolean isSuccess(){
		return this.getResult() == 1;
	}
	public String getOrderid() {
		return orderid;
	}
	public void setOrderid(String orderid) {
		this.orderid = orderid;
	}
	public String getGoodsid() {
		return goodsid;
	}
	public void setGoodsid(String goodsid) {
		this.goodsid = goodsid;
	}
	public String getGoodsname() {
		return goodsname;
	}
	public void setGoodsname(String goodsname) {
		this.goodsname = goodsname;
	}
	public String getGoodsdesc() {
		return goodsdesc;
	}
	public void setGoodsdesc(String goodsdesc) {
		this.goodsdesc = goodsdesc;
	}
	public String getGoodsfee() {
		return goodsfee;
	}
	public void setGoodsfee(String goodsfee) {
		this.goodsfee = goodsfee;
	}
	public String getNotifyurl() {
		return notifyurl;
	}
	public void setNotifyurl(String notifyurl) {
		this.notifyurl = notifyurl;
	}
	public String getMessage() {
		return message;
	}
	public void setMessage(String message) {
		this.message = message;
	}
	public String getErrcode() {
		return errcode;
	}
	public void setErrcode(String errcode) {
		this.errcode = errcode;
	}
	public String getMerchantId() {
		return merchantId;
	}
	public void setMerchantId(String merchantId) {
		this.merchantId = merchantId;
	}
	public String getPcorderid() {
		return pcorderid;
	}
	public void setPcorderid(String pcorderid) {
		this.pcorderid = pcorderid;
	}
	public String getInfo() {
		return info;
	}
	public void setInfo(String info) {
		this.info = info;
	}

	public String getSign() {
		return sign;
	}

	public void setSign(String sign) {
		this.sign = sign;
	}

	public String getSuccess() {
		return success;
	}

	public void setSuccess(String success) {
		this.success = success;
	}
}
